package com.qingcheng.service.impl;

import com.qingcheng.service.goods.CategoryService;
import com.qingcheng.service.goods.SkuService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 作缓存预热用，项目启动时候，先将数据存到redis中
 */
@Component
public class Init implements InitializingBean {

    @Autowired
    private CategoryService categoryService;

    @Autowired
    private SkuService skuService;

    public void afterPropertiesSet() throws Exception {
        System.out.println("---huanxunyure缓存预热----");
        //调入写入redis的方法
        categoryService.saveCategoryTreeToRedis();
        //将商品价格放入缓存
        skuService.saveAllPriceToRedis();//加载价格数据
    }
}
